Web development and Tech news Blog site. WEBISFREE.com

HOME > webdevetc

[WSL] How to reboot and restart Linux on Windows

Last Modified : 03 Mar, 2023 / Created : 04 Mar, 2023
726
View Count
We will learn how to restart or reboot Windows Subsystem for Linux (WSL or WSL 2).




# How to wsl restart(reboot)


We will only look at the methods briefly. What is the easiest and quickest way to restart?

Restarting from the Windows Service screen is one of the easy and quick methods. Follow the steps below.

  • Win + r Press key
  • Write down services.msc on input box
  • Find the LxssManager in service items
  • Select Restart (E) after right-clicking the mouse.

Now you can confirm that WSL has been restarted.


This is a very simple and fast method. Next, we will resolve it using the command line.


@ The first method of rebooting using the command line CMD command.
This method is preferred in cases where CLI is convenient. First, run CMD or Powershell as an administrator.

1. Run CMD or Powershell as administrator.


Now enter the command below and execute.
> Restart-Service LxssManager

or below command

> Get-Service LxssManager | Restart-Service

When executed, nothing is output. However, it can be seen that the open wsl is closed and rebooted. This method is also simple. However, the commands are not immediately understandable at a glance...


@ Second method for rebooting with the CMD command line.
The following is my personal favorite method. It is to input the command "wsl --shutdown". This can also be done in Powershell or CMD.
> wsl --shutdown

We have learned about several ways to restart a Linux sub-system under WSL up to this point..


! Reasons why a reboot was required.


To run MongoDB in a local development environment, I have been using the "sudo mongod" command to start the service. However, suddenly the command stopped working. In this situation, the most common solution is to try rebooting the system. Using this method, I rebooted the WSL and "sudo mongod" started functioning again. Regardless of the platform or hardware, it is important to realize that rebooting is often the most effective and efficient solution. This applies to WSL as well, so keep that in mind!
Perhaps you're looking for the following text as well?

Previous

Announcing the Nuxt 3 stable version release news.

Previous

[NodeJS] Resolving the issue of not being able to retrieve the request body in nodejs express when making post and patch requests through ajax.